/*****************************************************************************
 * vlc_menu_bar.c : GTK+ plugin for vlc
 *****************************************************************************/

#include "menubar.h"

#include "intf.h"
#include "vlc_connect.h"

#include "gtk_extra/gtk_extra.h"
#include "resources/stock_icons.h"

/* Widget */

static void vlc_menu_bar_class_init (VlcMenuBarClass *klass);
static void vlc_menu_bar_init       (VlcMenuBar *dialog);

G_DEFINE_TYPE (VlcMenuBar, vlc_menu_bar, GTK_TYPE_MENU_BAR);

/* Callbacks */

static void cb_activate_menu (GtkMenuItem *menuitem, gpointer user_data);

/* Private */
static GtkWidget* create_tools_menu_item (void);
static GtkWidget* create_fullscreen_menu_item (void);
static GtkWidget* create_zoom_menu_item (void);
static GtkWidget* create_help_menu_item (void);

static GtkWidget* create_quit_menu_item (void);

static void
vlc_menu_bar_class_init (VlcMenuBarClass *klass)
{}

static void
vlc_menu_bar_init (VlcMenuBar *menu_bar)
{}

GtkWidget*
vlc_menu_bar_new ()
{

  GtkWidget *menu_bar;
  
  GtkWidget *menubar_item;
  GtkWidget *submenu_item;
  GtkWidget *submenu2_item;
  GtkWidget *menu;
  GtkWidget *submenu;
  GtkWidget *image;

  menu_bar = g_object_new (VLC_TYPE_MENU_BAR, NULL);

  /* Media Menu */
  menubar_item = gtk_menu_item_new_with_qt_mnemonic_style (_("&Media"));
  menu = gtk_menu_new ();
  
  image = gtk_image_new_from_vlc_stock (VLC_STOCK_FILE, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_qt_mnemonic_style (image, _("Open &File..."));
  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_OPEN_FILE);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  image = gtk_image_new_from_vlc_stock (VLC_STOCK_OPEN, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_qt_mnemonic_style (image, _("Open Directory..."));
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);
  
  image = gtk_image_new_from_vlc_stock (VLC_STOCK_CDROM, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_qt_mnemonic_style (image, _("Open &Disc..." ));
  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_OPEN_DISC);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  image = gtk_image_new_from_vlc_stock (VLC_STOCK_NETWORK, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_qt_mnemonic_style (image, _("Open &Network..." ));
  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_OPEN_NETWORK);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  image = gtk_image_new_from_vlc_stock (VLC_STOCK_CAPTURE, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_qt_mnemonic_style (image, _("Open &Capture Device..." ));
  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_OPEN_CAPTURE_DEVICE);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);
  
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());

  image = gtk_image_new_from_vlc_stock (VLC_STOCK_STREAM, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_qt_mnemonic_style (image, _("&Streaming..."));
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);
  
  image = gtk_image_new_from_vlc_stock (VLC_STOCK_CONVERT, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_qt_mnemonic_style (image, _("Conve&rt / Save..."));
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_shell_append (GTK_MENU_SHELL(menu), gtk_separator_menu_item_new ());

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), create_quit_menu_item ());
  
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_item), menu);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), menubar_item);
  
  /*Playlist Menu*/
  menubar_item = gtk_menu_item_new_with_qt_mnemonic_style (_("&Playlist"));
  menu = gtk_menu_new ();

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Additionnal sources"));
    submenu = gtk_menu_new ();

      submenu2_item = gtk_check_menu_item_new_with_label (_("SAP Announcements"));
      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submenu2_item);

      submenu2_item = gtk_check_menu_item_new_with_label (_("Shoutcast radio listings"));
      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submenu2_item);

      submenu2_item = gtk_check_menu_item_new_with_label (_("Shoutcast TV listings"));
      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submenu2_item);

      submenu2_item = gtk_check_menu_item_new_with_label (_("Podcasts"));
      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submenu2_item);

      submenu2_item = gtk_menu_item_new_with_label (_("Configure podcasts..."));
      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submenu2_item);

      submenu2_item = gtk_check_menu_item_new_with_label (_("HAL devices detection"));
      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submenu2_item);

    gtk_menu_item_set_submenu (GTK_MENU_ITEM (submenu_item), submenu);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Show Playlist"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_PLAYLIST_SHOW);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Load playlist file..."));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_PLAYLIST_LOAD);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Save playlist to file..."));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_PLAYLIST_SAVE);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Unlock from interface"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_PLAYLIST_UNLOCK_FROM_INTERFACE);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_item), menu);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), menubar_item);
  
  /*Tools Menu*/

  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), create_tools_menu_item ());
  
  /*Audio Menu*/
  menubar_item = gtk_menu_item_new_with_qt_mnemonic_style (_("&Audio"));
  menu = gtk_menu_new ();
  
  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Audio Track"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_AUDIO_TRACK);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Audio Device"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_AUDIO_DEVICE);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Audio Channels"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_AUDIO_CHANNELS);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Visualization"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_AUDIO_VISUALISATION);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  image = gtk_image_new_from_vlc_stock (VLC_STOCK_EQUALIZER, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Equilizer"));
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (submenu_item), image);
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_AUDIO_EQUILIZER);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_item), menu);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), menubar_item);
  
  /*Video Menu*/
  menubar_item = gtk_menu_item_new_with_qt_mnemonic_style (_("&Video"));
  menu = gtk_menu_new ();
  
  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Video Track"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_VIDEO_TRACK);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  /* Fullscreen */    
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), create_fullscreen_menu_item ());

  /* Zoom */
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), create_zoom_menu_item ());

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Deinterlace"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_DEINTERLACE);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Aspect-ratio"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_ASPECT);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Crop"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_VIDEO_CROP);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_check_menu_item_new_with_label (_("Always on top"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_VIDEO_AOT);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Snapshot"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_VIDEO_SNAPSHOT);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Post processing"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_VIDEO_POST_PROCESSING);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_item), menu);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), menubar_item);
  
  /*Playback Menu*/
  menubar_item = gtk_menu_item_new_with_qt_mnemonic_style (_("&Playback"));
  menu = gtk_menu_new ();
  
  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Go to specific time..."));
  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_SEEK_TIME);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_item), menu);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), menubar_item);
  
  /*Help Menu*/

  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), create_help_menu_item ());
  
  return menu_bar;

}

GtkWidget*
vlc_menu_get_popup_menu (void)
{

  GtkWidget *menu;

  menu = gtk_menu_new ();

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), create_fullscreen_menu_item ());
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), create_zoom_menu_item ());

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), create_tools_menu_item ());

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), create_help_menu_item ());

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), create_quit_menu_item ());

  gtk_widget_show_all (menu);

	gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);

  return menu;

}

static GtkWidget*
create_quit_menu_item (void)
{

  GtkWidget *image;
  GtkWidget *menu_item;
  
  image = gtk_image_new_from_vlc_stock (VLC_STOCK_QUIT, VLC_ICON_SIZE_MENU);
  menu_item = gtk_image_menu_item_new_with_qt_mnemonic_style (image, _("&Quit"));
  g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_QUIT);

  return menu_item;

}

static GtkWidget*
create_fullscreen_menu_item (void)
{

  GtkWidget *menu_item;

  menu_item = gtk_check_menu_item_new_with_label (_("Fullscreen"));
  g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_FULLSCREEN);

  return menu_item;

}

static GtkWidget*
create_zoom_menu_item (void)
{

  GtkWidget *menu_item;
  GtkWidget *submenu_item;
  GtkWidget *image;
  GtkWidget *menu;

  image = gtk_image_new_from_vlc_stock (VLC_STOCK_MEDIA_ZOOM, VLC_ICON_SIZE_MENU);
  menu_item = gtk_image_menu_item_new_with_mnemonic (_("Zoom"));
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);

  menu = gtk_menu_new ();
  
  submenu_item = gtk_menu_item_new_with_label (_("1:4 Quarter"));
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_menu_item_new_with_label (_("1:2 Half"));
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_menu_item_new_with_label (_("1:1 Original"));
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_menu_item_new_with_label (_("2:1 Double"));
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);

  return menu_item;

}

static GtkWidget*
create_tools_menu_item (void)
{

  GtkWidget *menu_item;
  GtkWidget *submenu_item;
  GtkWidget *submenu2_item;
  GtkWidget *image;
  GtkWidget *submenu;
  GtkWidget *menu;

  menu_item = gtk_menu_item_new_with_qt_mnemonic_style (_("&Tools"));
  menu = gtk_menu_new ();
  
  image = gtk_image_new_from_vlc_stock (VLC_STOCK_LIST, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Playlist..."));
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (submenu_item), image);
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_TOOLS_PLAYLIST);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  image = gtk_image_new_from_vlc_stock (VLC_STOCK_MEDIA_PROPERTIES, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Extented settings..."));
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (submenu_item), image);
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_TOOLS_EXT_SETTINGS);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Add interfaces"));
    submenu = gtk_menu_new ();

      submenu2_item = gtk_menu_item_new_with_label (_("Mouse Gestures"));
      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submenu2_item);

      submenu2_item = gtk_menu_item_new_with_label (_("Web Interfaces"));
      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submenu2_item);

      submenu2_item = gtk_menu_item_new_with_label (_("Debug loggin"));
      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submenu2_item);

      submenu2_item = gtk_menu_item_new_with_label (_("Console"));
      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submenu2_item);

      submenu2_item = gtk_menu_item_new_with_label (_("Telnet Interface"));
      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submenu2_item);

      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), gtk_separator_menu_item_new ());

      submenu2_item = gtk_menu_item_new_with_label (_("Switch to skins"));
      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submenu2_item);

    gtk_menu_item_set_submenu (GTK_MENU_ITEM (submenu_item), submenu);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());

  submenu_item = gtk_check_menu_item_new_with_label (_("Minimal View..."));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_TOOLS_MINI_VIEW);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_check_menu_item_new_with_label (_("Advanced controls"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_TOOLS_ADVANCED_CONTROLS);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());

  image = gtk_image_new_from_vlc_stock (VLC_STOCK_MEDIA_WARNING, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Messages"));
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (submenu_item), image);
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_TOOLS_MESSAGES);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  image = gtk_image_new_from_vlc_stock (VLC_STOCK_MEDIA_INFO, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Media information"));
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (submenu_item), image);
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_TOOLS_MEDIA_INFO);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  image = gtk_image_new_from_vlc_stock (VLC_STOCK_MEDIA_INFO, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Codec information"));
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (submenu_item), image);
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_TOOLS_CODEC_INFO);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("VLM Configuration"));
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_TOOLS_VLM);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());

  image = gtk_image_new_from_vlc_stock (VLC_STOCK_SETTINGS, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Preferences..."));
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (submenu_item), image);
//  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_TOOLS_PREFERENCES);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);

 
  return menu_item;
  
}

static GtkWidget*
create_help_menu_item (void)
{

  GtkWidget *menu_item;
  GtkWidget *submenu_item;
  GtkWidget *image;
  GtkWidget *menu;

  menu_item = gtk_menu_item_new_with_qt_mnemonic_style (_("&Help" ));
  menu = gtk_menu_new ();
  
  image = gtk_image_new_from_vlc_stock (VLC_STOCK_HELP, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("Help"));
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (submenu_item), image);
  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_SHOW_HELP);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());

  image = gtk_image_new_from_vlc_stock (VLC_STOCK_ABOUT, VLC_ICON_SIZE_MENU);
  submenu_item = gtk_image_menu_item_new_with_mnemonic (_("About VLC media player..."));
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (submenu_item), image);
  g_signal_connect (G_OBJECT (submenu_item), "activate", G_CALLBACK (cb_activate_menu), (gpointer)ACTION_SHOW_ABOUT);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), submenu_item);

  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);

  return menu_item;

}

static void
cb_activate_menu (GtkMenuItem *menuitem, gpointer user_data)
{

  int i;
  
  i = (int)user_data;
  
  switch (i)
   {   
    case ACTION_OPEN_FILE:
      show_open_file ();
    break;
    
    case ACTION_OPEN_DISC:
      show_open_disc ();
    break;
    
    case ACTION_OPEN_NETWORK:
      show_open_network ();
    break;
    
    case ACTION_OPEN_CAPTURE_DEVICE:
      show_open_capture_device ();
    break;

    case ACTION_FULLSCREEN:
      fullscreen ();
    break;

    case ACTION_SEEK_TIME:
      show_seek_time ();
    break;

    case ACTION_SHOW_HELP:
      show_help ();
    break;
    
    case ACTION_SHOW_ABOUT:
      show_about ();
    break;
    
    case ACTION_QUIT:
      quit ();
    break;
    
   }
   
  (void)user_data;
  (void)menuitem;

}
